package com.dyz.leetcode._12_linkedList;


import com.dyz.leetcode.ListNode;
import com.dyz.leetcode.Node;

import java.util.HashMap;

public class _138_copyRandomList {
    private HashMap<Node, Node> map = new HashMap<>();
    public Node copyRandomList(Node head) {
        if(head==null){return null;}

        Node newNode  = new Node(head.val);
        map.put(head, newNode);

        newNode.next = copyRandomList(head.next);
        newNode.random = map.get(head.random);
        return newNode;
    }
}
